package model.type;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;

import db.EmployeeRoleTypeDAO;

public class EmployeeRoleType {
	private static HashMap<Integer, EmployeeRoleType> map 
	= new HashMap<Integer, EmployeeRoleType>();
	
	private int id;
	private String type;	

	// LOAD EVERYTHING INTO HASHMAP FOR QUICK REFERENECE IN THE FUTURE
	static{		
		for(EmployeeRoleType t: EmployeeRoleTypeDAO.getAll()){
			map.put(t.getId(), t);
		}		
	}
	
	public static EmployeeRoleType getEmployeeRoleType(int id){
		return map.get(id);
	}
	
	public EmployeeRoleType(int id, String type) {
		this.id = id;
		this.type = type;
	}
	
	public int getId() {
		return id;
	}

	public String getType() {
		return type;
	}
	
	public static ArrayList<EmployeeRoleType> getAll(){
		ArrayList<EmployeeRoleType> list = new ArrayList<EmployeeRoleType>();
		for(Entry<Integer, EmployeeRoleType> e: map.entrySet()){
			list.add(e.getValue());
		}
		return list;
	}
	
}
